﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <script type="text/javascript" src="../js/jquery-1.10.2.js"></script>
    <script type="text/javascript" src="../js/Interface.js"></script>
    <script type="text/javascript" src="../js/Helpers.js"></script>
</head>
<body>
    <div id="content">
    </div>
    <script type="text/javascript">
        /* Extend function, improved. */
        function extend(subClass, superClass) {
            var F = function () { };
            F.prototype = superClass.prototype;
            subClass.prototype = new F();
            subClass.prototype.constructor = subClass;
            subClass.superclass = superClass.prototype;
            if (superClass.prototype.constructor == Object.prototype.constructor) {
                superClass.prototype.constructor = superClass;
            }
        }

        /* Class Person. */
        function Person(name) {
            this.name = name;
        }
        Person.prototype.getName = function () {
            return this.name;
        }

        /* Class Author. */
        function Author(name, books) {
            Author.superclass.constructor.call(this, name);
            this.books = books;
        }
        extend(Author, Person);
        Author.prototype.getBooks = function () {
            return this.books;
        };
        Author.prototype.getName = function () {
            var name = Author.superclass.getName.call(this);
            return name + ', Author of ' + this.getBooks().join(', ');
        };

        $(function () {
            var author = [];
            author[0] = new Author('Dustin Diaz', ['JavaScript Design Patterns']);
            author[1] = new Author('Ross Harmes', ['JavaScript Design Patterns']);

            $("#content").html(String.format("{0}", author[1].getName()));
        });
    </script>
</body>
</html>
